package com.lqwu.mallchatserver.common.domain.enums;

import com.lqwu.mallchatserver.user.model.enums.ItemTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 通用枚举类
 * Yes 或者 No
 */
@AllArgsConstructor
@Getter
public enum YesOrNoEnums {
    Yes(1, "是"),
    NO(0, "否"),
    ;

    private final Integer status;
    private final String desc;

    private static Map<Integer, YesOrNoEnums> cache;

    static {
        cache = Arrays.stream(YesOrNoEnums.values()).collect(Collectors.toMap(YesOrNoEnums::getStatus, Function.identity()));
    }

    public static YesOrNoEnums of(Integer status) {
        return cache.get(status);
    }
}
